package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 文件复制
 */
public class CopyDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("./image.png");
        FileOutputStream fos = new FileOutputStream("./image_cp.png");

        int d;

        //获取当前系统时间
        long start = System.currentTimeMillis();
        //从原文件读取1个字节
        while((d = fis.read())!=-1) {
            fos.write(d);
        }
        long end = System.currentTimeMillis();

        System.out.println("复制完毕,耗时:"+(end-start)+"ms");
        fis.close();
        fos.close();
    }
}






